package com.yungu.swift.assets.passenger.service.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.annotation.Service;
import com.yungu.swift.assets.passenger.dao.PassengerMapper;
import com.yungu.swift.assets.passenger.dao.PassengerRechargeMapper;
import com.yungu.swift.assets.passenger.model.dto.PassengerRechargeDto;
import com.yungu.swift.assets.passenger.service.PassengerRechargeCityService;
import com.yungu.swift.assets.passenger.service.PassengerWalletService;
import com.yungu.swift.base.ResponseData;
import com.yungu.swift.system.finance.service.FinancePrepayService;
import com.yungu.swift.system.sys.service.SysAccountPlatformService;
import com.yungu.swift.system.sys.service.SysCityService;
import com.yungu.swift.utils.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Collection;
import java.util.Map;

/**
 * Created by cuixiuyin on 2018/3/27.
 */
@Service
public class PassengerWalletServiceImpl implements PassengerWalletService {

    @Autowired
    private PassengerMapper passengerMapper;
    @Autowired
    private PassengerRechargeMapper passengerRechargeMapper;
    @Autowired
    private PassengerRechargeCityService passengerRechargeCityService;
    @Reference
    private FinancePrepayService financePrepayService;
    @Reference
    private SysCityService sysCityService;
    @Reference
    private SysAccountPlatformService sysAccountPlatformService;


    @Override
    public ResponseData<Map<String, Object>> getWallet(String uuid) {
        //根据用户ID获取钱包信息，主要包括账户余额，优惠券张数
        Map<String, Object> map = MapUtils.build(2);
        map.put("uuid", uuid);
        return ResponseData.buildSuccessResponse(passengerMapper.getWallet(map));
    }

    @Override
    public ResponseData<Collection<PassengerRechargeDto>> listDenominations(String areaCode) {
        String cityUuid = sysCityService.getCityUuidByAdCode(areaCode).getData();
        return passengerRechargeCityService.findPassengerRechargeCity(cityUuid);
    }
}
